package cn.wolfcode.controller;

import cn.wolfcode.domain.Destination;
import cn.wolfcode.domain.Region;
import cn.wolfcode.domain.Strategy;
import cn.wolfcode.domain.StrategyCatalog;
import cn.wolfcode.service.IDestinationService;
import cn.wolfcode.service.IRegionService;
import cn.wolfcode.service.IStrategyCatalogService;
import cn.wolfcode.service.IStrategyService;
import cn.wolfcode.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestController {

    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @GetMapping("hotRegion")
    public Object hotRegion(){
        List<Region> regions = regionService.queryIshot();
        return JsonResult.success(regions);
    }

    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> list = destinationService.getDestAllById(regionId);
        return JsonResult.success(list);
    }

    @GetMapping("toasts")
    public Object toasts(String destId){
        List<Destination> list = destinationService.queryToasts(destId);
        return JsonResult.success(list);
    }
    @GetMapping("catalogs")
    public Object detail(String destId){
        List<StrategyCatalog> list = strategyCatalogService.findByDestId(destId);
        return JsonResult.success(list);
    }
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){
        List<Strategy> list = strategyService.viewnumTop3(destId);
        return JsonResult.success(list);
    }

}
